﻿@using EpiInfoCloudMagpiBridge.Models
@model  EpiInfoCloudMagpiBridge.Models.MagpiAzureMappingHelper

@{
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Index</title>
</head>
@using (Html.BeginForm("Save", "MagpiAzureMapping", FormMethod.Post, Model))
{
    <body>
        <h3>Manage Registered Datasets</h3>
        <hr />
        <table class="table">
            <tr>
                <th>
                    @Html.DisplayNameFor(model => model.MagpiTotalList[0].EWAVUserID)
                </th>
                <th>
                    @Html.DisplayNameFor(model => model.MagpiTotalList[0].SurveyName)
                </th>
                <th>
                    @Html.DisplayNameFor(model => model.MagpiTotalList[0].SurveyID)
                </th>
                <th>
                    @Html.DisplayNameFor(model => model.MagpiTotalList[0].MobileServiceTableName)
                </th>
                <th></th>
            </tr>

            @foreach (var item in Model.MagpiAzureRegisteredList)
            {
                if (item.EWAVUserID == ApplicationModel.CurrentEwavUserId)
                {

                    <tr>
                        <td>
                            @Html.DisplayFor(modelItem => item.EWAVUserID)
                        </td>
                        <td>
                            @Html.DisplayFor(modelItem => item.SurveyName)
                        </td>
                        <td>
                            @Html.DisplayFor(modelItem => item.SurveyID)
                        </td>
                        <td>
                            @Html.DisplayFor(modelItem => item.MobileServiceTableName)
                        </td>
                        <td>
                            @Html.ActionLink("Edit", "Edit", new { id = item.Id }) |
                            @*@Html.ActionLink("Details", "Details", new { id=item.Id }) |*@
                            @Html.ActionLink("Delete", "Delete", new { id = item.Id })
                        </td>
                    </tr>
                }
            }

        </table>

        <table>
            @{
                if (Model.DropDownCollection.Items.Any())
                {
                    @Html.ActionLink("Create new Record", "Create")

                }
                else
                {
                    <tr> <td><span>There are no unregistered Magpi datasets on this server.</span></td> </tr>

                }
            }
        </table>

    </body>
}
</html>
